<%@page import="java.util.List"%>
<%@page import="com.charlie.beans.Product"%>

<%@include file="/header.jsp" %>
<script>
    $(function() {
        $('.item_block_bottom a').click(function() {
            var itemId = parseInt($(this).attr('itemId'));
            if (!itemId)
                return;
            cart_query('add', itemId, 1, null);
        });
    });
</script>

<div class="left_side">
    <jsp:include page="/blocks/conditionalLeftBar.jsp" />
</div>

<div class="right_side">
    <div class="white_block index_block">
        <table class="typycal_table">
            <tbody>
                <tr>
        <%
            List<Product> goods_list = (List<Product>)request.getAttribute("items_list");
            if (goods_list != null) {
                int i = 1;
                for (Product item : goods_list) {
        %>
                    <td>
                        <jsp:include page="/blocks/item.jsp">
                            <jsp:param name="id" value="<%= item.getProductId() %>" />
                            <jsp:param name="name" value="<%= item.getName() %>" />
                            <jsp:param name="image" value="<%= item.getImage() %>" />
                            <jsp:param name="cost" value="<%= item.getCost() %>" />
                        </jsp:include>
                    </td>
        <%
                    if (i % 3 == 0)
                        out.print("</tr><tr>");
                    i++;
                }
                for (; i % 3 == 0; i++)
                    out.print("<td></td>");
            } else {
        %>
            <b>No products found</b>
        <%
            }
        %>
                </tr>
            </tbody>
        </table>
    </div>

    <jsp:include page="/blocks/pages.jsp">
        <jsp:param name="path" value="" />
    </jsp:include>
</div>

<%@include file="/footer.jsp" %>